<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateCustomerDepartmentSiteLocationRelationTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('customer_department_site_location_relation', function (Blueprint $table) {
            $table->id();
            $table->unsignedInteger('taskId')->default(0)->comment('勘址任务ID');
            $table->unsignedTinyInteger('source')->default(0)->comment('来源(同选址来源)');
            $table->string('relationNumber', 36)->default('')->comment('关联编号');
            $table->unsignedInteger('relationId')->default(0)->comment('关联Id');
            $table->unsignedTinyInteger('projectPhase')->default(0)->comment('项目进度（同勘址任务）');
            $table->unsignedInteger('isDeleted')->default(0)->comment('是否删除');
            $table->unsignedInteger('createdAt')->default(0)->comment('创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');
            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '勘址任务关联房源于选址';

            $table->index('taskId', 'idx_taskId');
            $table->index('relationNumber', 'idx_relationNumber');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('customer_department_site_location_relation');
    }
}
